/*
 * Copyright 2011 Niklas Kyster Rasmussen
 * 
 * This file is part of WotXP.
 *
 * WotXP is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * WotXP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WotXP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

package net.nikr.wot.gui;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import net.nikr.wot.core.GuiProgram;
import net.nikr.wot.core.Main;


public class MainFrame implements WindowListener{
	
	private JFrame jFrame;
	private MainPanel mainPanel;
	private GuiProgram program;

	public MainFrame(GuiProgram program) {
		this.program = program;
		jFrame = new JFrame();
		jFrame.setTitle(Main.PROGRAM_NAME+" "+Main.PROGRAM_VERSION);
		jFrame.setLocation(0, 0);
		jFrame.setSize(800, 600);
		jFrame.addWindowListener(this);
		jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		mainPanel = new MainPanel(this);
		jFrame.getContentPane().add(mainPanel.getPanel());
	}
	
	public void show(){
		jFrame.setVisible(true);
		mainPanel.show();
	}

	@Override
	public void windowOpened(WindowEvent e) {}

	@Override
	public void windowClosing(WindowEvent e) {
		program.exit();
	}

	@Override
	public void windowClosed(WindowEvent e) {}

	@Override
	public void windowIconified(WindowEvent e) {}

	@Override
	public void windowDeiconified(WindowEvent e) {}

	@Override
	public void windowActivated(WindowEvent e) {}

	@Override
	public void windowDeactivated(WindowEvent e) {}

	public JFrame getFrame() {
		return jFrame;
	}
}
